unit U_AumentaDescricao;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, Mask, ToolEdit, CurrEdit;

type
  TF_AumentaDescricao = class(TForm)
    Label1: TLabel;
    E_Desc_Prod: TEdit;
    Label3: TLabel;
    BitBtn1: TBitBtn;
    E_ValorVenda: TCurrencyEdit;
    E_Qtde: TRxCalcEdit;
    Label2: TLabel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure E_Desc_ProdKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure E_Desc_ProdEnter(Sender: TObject);
    procedure E_ValorVendaKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure E_QtdeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  F_AumentaDescricao: TF_AumentaDescricao;

implementation

uses U_Menu, uFunRede, U_Vendas;

{$R *.dfm}

procedure TF_AumentaDescricao.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if trim(E_Desc_Prod.Text) <>'' then
    F_Vendas.vDescricao:=trim(E_Desc_Prod.Text);//+' '+E_Cor.Text+' '+E_Numero.Text);
  if E_ValorVenda.Value > 0  then
    F_Vendas.vPreco:=StrToCurr(trim(E_ValorVenda.Text));
  if E_Qtde.Value > 0  then
    F_Vendas.iQtde:=StrToFloat(trim(E_Qtde.Text))
  else F_Vendas.iQtde:=1;

  action:=caFree;

end;

procedure TF_AumentaDescricao.FormCreate(Sender: TObject);
begin
  ArredondaComponentes(F_AumentaDescricao);
  ArredondaComponentes(F_AumentaDescricao.E_Desc_Prod);
  ArredondaComponentes(F_AumentaDescricao.E_ValorVenda);
  ArredondaComponentes(F_AumentaDescricao.E_Qtde);

  F_AumentaDescricao.E_Desc_Prod.Color:=Menu_Retaguarda.vCor;
  F_AumentaDescricao.E_ValorVenda.Color:=Menu_Retaguarda.vCor;
  F_AumentaDescricao.E_Qtde.Color:=Menu_Retaguarda.vCor;
end;

procedure TF_AumentaDescricao.FormShow(Sender: TObject);
begin
  Limpatexto(F_AumentaDescricao);
  E_Desc_Prod.Text:=F_Vendas.vDescricao;
  E_ValorVenda.Value:=F_Vendas.vPreco;
  E_Qtde.Value:= F_Vendas.iQtde;
end;

procedure TF_AumentaDescricao.E_Desc_ProdKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  case key of
    VK_RETURN:E_ValorVenda.SetFocus;
  end;
end;

procedure TF_AumentaDescricao.E_Desc_ProdEnter(Sender: TObject);
begin
  E_Desc_Prod.Text:=trim(E_Desc_Prod.Text)+' ';
end;

procedure TF_AumentaDescricao.E_ValorVendaKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  case key of
    VK_RETURN:E_Qtde.SetFocus;
  end;
end;

procedure TF_AumentaDescricao.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  if E_ValorVenda.Value <= 0 then
  begin
     Mensagem(#13+'Digite um valor!');
     E_ValorVenda.SetFocus;
     CanClose:=false;
  end;
end;

procedure TF_AumentaDescricao.E_QtdeKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case key of
    VK_RETURN:F_AumentaDescricao.Close;
  end;
end;

end.
